package org.cx.comparator;

import org.cx.comparator.compare.ObjectCompare;
import org.cx.comparator.compare.ReflectAsmCompare;
import org.cx.comparator.expression.ExpressionInvoker;
import org.cx.comparator.expression.QLExpressionInvoker;
import org.cx.comparator.map.AnnotationProcessor;
import org.cx.comparator.map.MapProcessor;
import org.cx.comparator.map.ProviderProcessor;
import lombok.Data;
import org.springframework.context.ApplicationContext;


@Data
public class ComparatorConfiguration {

    private ComparatorRegistry comparatorRegistry = new ComparatorRegistry(this);
    private ApplicationContext applicationContext;
    private MapProcessor mapProcessor;
    private ObjectCompare objectCompare = new ReflectAsmCompare(this);
    private ExpressionInvoker expressionInvoker = new QLExpressionInvoker(applicationContext);

    public ComparatorConfiguration() {
        initMapProcessor();
    }

    private void initMapProcessor() {
        ProviderProcessor providerProcessor = new ProviderProcessor(this);
        AnnotationProcessor annotationProcessor = new AnnotationProcessor(this);
        providerProcessor.setNext(annotationProcessor);
        this.mapProcessor = providerProcessor;
    }
}
